package cn.qyd.javathread;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author 邱运铎
 * @date 2024-03-09 19:53
 */
public class MyThreadMain {
    //public static volatile AtomicInteger num = new AtomicInteger(0);
    public static AtomicInteger num = new AtomicInteger(0);
   // public static int num = 0;
    public static void main(String[] args) {
        Thread thread = new MyThread();
        thread.start();
        for (int i = 0; i < 1000; i++) {
            MyThreadMain.num.incrementAndGet();
            //MyThreadMain.num++;
            //System.out.println("主线程: ->  " + i);
            if(i == 999)
                System.out.println("主线程for循环结束： num="+MyThreadMain.num);
        }
        System.out.println(MyThreadMain.num);
    }
}
